home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / show / gs_src_gs.lha / gs5.03 / gdevcgml.h < prev    next >
Text File  |  1996-09-02  |  14KB  |  404 lines

  1. /* Copyright (C) 1995, 1996 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gdevcgml.h */
  20. /* Interface definitions for CGM-writing library */
  21.  
  22. /* The names in the following follow the CGM standard exactly, */
  23. /* except that we have substituted the American spellings of */
  24. /* color (colour) and center (centre). */
  25.  
  26. /* ================ Types ================ */
  27.  
  28. /* Define the abstract type for the CGM writer state. */
  29. typedef struct cgm_state_s cgm_state;
  30.  
  31. /* Define the type for the allocator used by the CGM writer. */
  32. typedef struct cgm_allocator_s {
  33.     void *private_data;
  34.     void *(*alloc)(P2(void *, uint));
  35.     void (*free)(P2(void *, void *));
  36. } cgm_allocator;
  37.  
  38. /* Define types for CGM coordinates. */
  39. typedef int cgm_int;
  40. typedef double cgm_real;
  41. typedef union cgm_vdc_s {
  42.     cgm_int integer;
  43.     cgm_real real;
  44. } cgm_vdc;
  45. typedef struct cgm_int_point_s {
  46.     cgm_int x, y;
  47. } cgm_int_point;
  48. typedef struct cgm_real_point_s {
  49.     cgm_real x, y;
  50. } cgm_real_point;
  51. typedef union cgm_point_s {
  52.     cgm_int_point integer;
  53.     cgm_real_point real;
  54. } cgm_point;
  55.  
  56. /* Define types for colors. */
  57. typedef struct cgm_rgb_s {
  58.     cgm_int r, g, b;
  59. } cgm_rgb;
  60. typedef union cgm_color_s {
  61.     cgm_int index;
  62.     cgm_rgb rgb;
  63. } cgm_color;
  64.  
  65. /*
  66.  * Define other types used in CGM elements or API calls.
  67.  * If cgm_xxx is an enumerated type, let xxx' be xxx with any of the
  68.  * following words dropped: mode, specification, type; then the values
  69.  * of the enumerated type are named cgm_xxx'_yyy.
  70.  */
  71. typedef enum {
  72.     cgm_vdc_integer = 0,
  73.     cgm_vdc_real
  74. } cgm_vdc_type;
  75. typedef struct cgm_string_s {
  76.     const char *chars;
  77.     uint length;
  78. } cgm_string;
  79. typedef enum {
  80.     cgm_scaling_abstract = 0,
  81.     cgm_scaling_metric
  82. } cgm_scaling_mode;
  83. typedef enum {
  84.     cgm_color_selection_indexed = 0,
  85.     cgm_color_selection_direct
  86. } cgm_color_selection_mode;
  87. typedef enum {
  88.     cgm_line_marker_absolute = 0,
  89.     cgm_line_marker_scaled
  90. } cgm_line_marker_specification_mode;
  91. typedef cgm_line_marker_specification_mode
  92.   cgm_line_width_specification_mode, cgm_marker_size_specification_mode,
  93.   cgm_edge_width_specification_mode;
  94. typedef union cgm_line_marker_extent_s {
  95.     cgm_vdc absolute;
  96.     cgm_real scaled;
  97. } cgm_line_marker_extent;
  98. typedef cgm_line_marker_extent
  99.   cgm_line_width, cgm_marker_size, cgm_edge_width;
  100. typedef enum {
  101.     cgm_transparency_off = 0,
  102.     cgm_transparency_on
  103. } cgm_transparency;
  104. typedef enum {
  105.     cgm_clip_off = 0,
  106.     cgm_clip_on
  107. } cgm_clip_indicator;
  108. typedef struct cgm_precision_s {
  109.     enum { cgm_representation_floating, cgm_representation_fixed } representation;
  110.     int exponent_or_whole_width;
  111.     int fraction_width;
  112. } cgm_precision;
  113. typedef enum {
  114.     cgm_line_solid = 1,
  115.     cgm_line_dash,
  116.     cgm_line_dot,
  117.     cgm_line_dash_dot,
  118.     cgm_line_dash_dot_dot
  119. } cgm_line_type;
  120. typedef enum {
  121.     cgm_marker_dot = 1,
  122.     cgm_marker_plus,
  123.     cgm_marker_asterisk,
  124.     cgm_marker_circle,
  125.     cgm_marker_cross
  126. } cgm_marker_type;
  127. typedef enum {
  128.     cgm_text_precision_string = 0,
  129.     cgm_text_precision_character,
  130.     cgm_text_precision_stroke
  131. } cgm_text_precision;
  132. typedef enum {
  133.     cgm_text_path_right = 0,
  134.     cgm_text_path_left,
  135.     cgm_text_path_up,
  136.     cgm_text_path_down
  137. } cgm_text_path;
  138. typedef enum {
  139.     cgm_text_horizontal_normal = 0,
  140.     cgm_text_horizontal_left,
  141.     cgm_text_horizontal_center,
  142.     cgm_text_horizontal_right,
  143.     cgm_text_horizontal_continuous
  144. } cgm_text_alignment_horizontal;
  145. typedef enum {
  146.     cgm_text_vertical_normal = 0,
  147.     cgm_text_vertical_top,
  148.     cgm_text_vertical_cap,
  149.     cgm_text_vertical_half,
  150.     cgm_text_vertical_base,
  151.     cgm_text_vertical_bottom,
  152.     cgm_text_vertical_continuous
  153. } cgm_text_alignment_vertical;
  154. typedef enum {
  155.     cgm_interior_style_hollow = 0,
  156.     cgm_interior_style_solid,
  157.     cgm_interior_style_pattern,
  158.     cgm_interior_style_hatch,
  159.     cgm_interior_style_empty
  160. } cgm_interior_style;
  161. typedef enum {
  162.     cgm_hatch_horizontal = 1,
  163.     cgm_hatch_vertical,
  164.     cgm_hatch_positive_slope,
  165.     cgm_hatch_negative_slope,
  166.     cgm_hatch_combined_v_h_slant,
  167.     cgm_hatch_combined_l_r_slant
  168. } cgm_hatch_index;
  169. typedef enum {
  170.     cgm_arc_closure_pie = 0,
  171.     cgm_arc_closure_chord
  172. } cgm_arc_closure;
  173. typedef enum {
  174.     cgm_edge_out_invisible = 0,
  175.     cgm_edge_out_visible,
  176.     cgm_edge_out_close_invisible,
  177.     cgm_edge_out_close_visible
  178. } cgm_edge_out;
  179. typedef struct cgm_polygon_edge_s {
  180.     cgm_point vertex;
  181.     cgm_edge_out edge_out;
  182. } cgm_polygon_edge;
  183. typedef enum {
  184.     cgm_cell_mode_run_length = 0,
  185.     cgm_cell_mode_packed
  186. } cgm_cell_representation_mode;
  187. typedef enum {
  188.     cgm_edge_solid = 1,
  189.     cgm_edge_dash,
  190.     cgm_edge_dot,
  191.     cgm_edge_dash_dot,
  192.     cgm_edge_dash_dot_dot
  193. } cgm_edge_type;
  194. typedef enum {
  195.     cgm_aspect_source_individual = 0,
  196.     cgm_aspect_source_bundled
  197. } cgm_aspect_source;
  198. typedef enum {
  199.     cgm_aspect_line_type = 0,
  200.     cgm_aspect_line_width,
  201.     cgm_aspect_line_color,
  202.     cgm_aspect_marker_type,
  203.     cgm_aspect_marker_size,
  204.     cgm_aspect_marker_color,
  205.     cgm_aspect_text_font_index,
  206.     cgm_aspect_text_precision,
  207.     cgm_aspect_character_expansion_factor,
  208.     cgm_aspect_character_spacing,
  209.     cgm_aspect_text_color,
  210.     cgm_aspect_interior_style,
  211.     cgm_aspect_fill_color,
  212.     cgm_aspect_hatch_index,
  213.     cgm_aspect_pattern_index,
  214.     cgm_aspect_edge_type,
  215.     cgm_aspect_edge_width,
  216.     cgm_aspect_edge_color
  217. } cgm_aspect_type;
  218. typedef struct cgm_aspect_source_flag_s {
  219.     cgm_aspect_type type;
  220.     cgm_aspect_source source;
  221. } cgm_aspect_source_flag;
  222.  
  223. /* ================ API ================ */
  224.  
  225. typedef enum {
  226.     cgm_result_ok = 0,
  227.     cgm_result_wrong_state = -1,
  228.     cgm_result_out_of_range = -2,
  229.     cgm_result_io_error = -3,
  230.     cgm_result_out_of_memory = -4
  231. } cgm_result;
  232.  
  233. /* ---------------- Initialize/terminate ---------------- */
  234.  
  235. cgm_state *cgm_initialize(P2(FILE *, const cgm_allocator *));
  236. cgm_result cgm_terminate(P1(cgm_state *));
  237.  
  238. /* ---------------- Metafile elements ---------------- */
  239.  
  240. typedef struct cgm_metafile_elements_s {
  241.     cgm_int metafile_version;
  242.     cgm_string metafile_description;    
  243.     cgm_vdc_type vdc_type;
  244.     int integer_precision;
  245.     cgm_precision real_precision;
  246.     int index_precision;
  247.     int color_precision;
  248.     int color_index_precision;
  249.     cgm_int maximum_color_index;
  250.     cgm_color color_value_extent[2];
  251.     const int *metafile_element_list;
  252.       int metafile_element_list_count;
  253.     const cgm_string *font_list;
  254.       int font_list_count;
  255.     /* character_set_list */
  256.     /* character_coding_announcer */
  257. } cgm_metafile_elements;
  258. #define cgm_set_METAFILE_VERSION    (1L<<0)
  259. #define cgm_set_METAFILE_DESCRIPTION    (1L<<1)
  260. #define cgm_set_VDC_TYPE        (1L<<2)
  261. #define cgm_set_INTEGER_PRECISION    (1L<<3)
  262. #define cgm_set_REAL_PRECISION        (1L<<4)
  263. #define cgm_set_INDEX_PRECISION        (1L<<5)
  264. #define cgm_set_COLOR_PRECISION        (1L<<6)
  265. #define cgm_set_COLOR_INDEX_PRECISION    (1L<<7)
  266. #define cgm_set_MAXIMUM_COLOR_INDEX    (1L<<8)
  267. #define cgm_set_COLOR_VALUE_EXTENT    (1L<<9)
  268. #define cgm_set_METAFILE_ELEMENT_LIST    (1L<<10)
  269. #define cgm_set_FONT_LIST        (1L<<11)
  270. #define cgm_set_CHARACTER_SET_LIST    (1L<<12)
  271. #define cgm_set_CHARACTER_CODING_ANNOUNCER    (1L<<13)
  272.  
  273. cgm_result
  274.     cgm_BEGIN_METAFILE(P3(cgm_state *, const char *, uint)),
  275.     cgm_set_metafile_elements(P3(cgm_state *,
  276.                      const cgm_metafile_elements *, long)),
  277.     cgm_END_METAFILE(P1(cgm_state *));
  278.  
  279. /* ---------------- Picture elements ---------------- */
  280.  
  281. typedef struct cgm_picture_elements_s {
  282.     cgm_scaling_mode scaling_mode;
  283.     cgm_real scale_factor;
  284.     cgm_color_selection_mode color_selection_mode;
  285.     cgm_line_width_specification_mode line_width_specification_mode;
  286.     cgm_marker_size_specification_mode marker_size_specification_mode;
  287.     cgm_edge_width_specification_mode edge_width_specification_mode;
  288.     cgm_point vdc_extent[2];
  289.     cgm_color background_color;
  290. } cgm_picture_elements;
  291. #define cgm_set_SCALING_MODE        (1L<<0)
  292. #define cgm_set_COLOR_SELECTION_MODE    (1L<<1)
  293. #define cgm_set_LINE_WIDTH_SPECIFICATION_MODE    (1L<<2)
  294. #define cgm_set_MARKER_SIZE_SPECIFICATION_MODE    (1L<<3)
  295. #define cgm_set_EDGE_WIDTH_SPECIFICATION_MODE    (1L<<4)
  296. #define cgm_set_VDC_EXTENT        (1L<<5)
  297. #define cgm_set_BACKGROUND_COLOR    (1L<<6)
  298.  
  299. cgm_result
  300.     cgm_BEGIN_PICTURE(P3(cgm_state *, const char *, uint)),
  301.     cgm_set_picture_elements(P3(cgm_state *,
  302.                     const cgm_picture_elements *, long)),
  303.     cgm_BEGIN_PICTURE_BODY(P1(cgm_state *)),
  304.     cgm_END_PICTURE(P1(cgm_state *));
  305.  
  306. /* ---------------- Control elements ---------------- */
  307.  
  308. cgm_result
  309.     cgm_VDC_INTEGER_PRECISION(P2(cgm_state *, int)),
  310.     cgm_VDC_REAL_PRECISION(P2(cgm_state *, const cgm_precision *)),
  311.     cgm_AUXILIARY_COLOR(P2(cgm_state *, const cgm_color *)),
  312.     cgm_TRANSPARENCY(P2(cgm_state *, cgm_transparency)),
  313.     cgm_CLIP_RECTANGLE(P2(cgm_state *, const cgm_point [2])),
  314.     cgm_CLIP_INDICATOR(P2(cgm_state *, cgm_clip_indicator));
  315.  
  316. /* ---------------- Graphical primitive elements ---------------- */
  317.  
  318. cgm_result
  319.     cgm_POLYLINE(P3(cgm_state *, const cgm_point *, int)),
  320.     cgm_DISJOINT_POLYLINE(P3(cgm_state *, const cgm_point *, int)),
  321.     cgm_POLYMARKER(P3(cgm_state *, const cgm_point *, int)),
  322.     cgm_TEXT(P5(cgm_state *, const cgm_point *, bool, const char *, uint)),
  323.     cgm_RESTRICTED_TEXT(P7(cgm_state *, const cgm_vdc *, const cgm_vdc *,
  324.                    const cgm_point *, bool, const char *, uint)),
  325.     cgm_APPEND_TEXT(P4(cgm_state *, bool, const char *, uint)),
  326.     cgm_POLYGON(P3(cgm_state *, const cgm_point *, int)),
  327.     cgm_POLYGON_SET(P3(cgm_state *, const cgm_polygon_edge *, int)),
  328.     cgm_CELL_ARRAY(P9(cgm_state *, const cgm_point * /*[3]*/, cgm_int,
  329.               cgm_int, cgm_int, cgm_cell_representation_mode,
  330.               const byte *, uint, uint)),
  331.     cgm_RECTANGLE(P3(cgm_state *, const cgm_point *, const cgm_point *)),
  332.     cgm_CIRCLE(P3(cgm_state *, const cgm_point *, const cgm_vdc *)),
  333.     cgm_CIRCULAR_ARC_3_POINT(P4(cgm_state *, const cgm_point *,
  334.                     const cgm_point *, const cgm_point *)),
  335.     cgm_CIRCULAR_ARC_3_POINT_CLOSE(P5(cgm_state *, const cgm_point *,
  336.                       const cgm_point *,
  337.                       const cgm_point *, cgm_arc_closure)),
  338.     cgm_CIRCULAR_ARC_CENTER(P7(cgm_state *, const cgm_point *,
  339.                    const cgm_vdc *, const cgm_vdc *,
  340.                    const cgm_vdc *, const cgm_vdc *,
  341.                    const cgm_vdc *)),
  342.     cgm_CIRCULAR_ARC_CENTER_CLOSE(P8(cgm_state *, const cgm_point *,
  343.                      const cgm_vdc *, const cgm_vdc *,
  344.                      const cgm_vdc *, const cgm_vdc *,
  345.                      const cgm_vdc *, cgm_arc_closure)),
  346.     cgm_ELLIPSE(P4(cgm_state *, const cgm_point *, const cgm_point *,
  347.                const cgm_point *)),
  348.     cgm_ELLIPTICAL_ARC(P8(cgm_state *, const cgm_point *,
  349.                   const cgm_point *, const cgm_point *,
  350.                   const cgm_vdc *, const cgm_vdc *,
  351.                   const cgm_vdc *, const cgm_vdc *)),
  352.     cgm_ELLIPTICAL_ARC_CLOSE(P9(cgm_state *, const cgm_point *,
  353.                     const cgm_point *, const cgm_point *,
  354.                     const cgm_vdc *, const cgm_vdc *,
  355.                     const cgm_vdc *, const cgm_vdc *,
  356.                     cgm_arc_closure));
  357.  
  358. /* ---------------- Attribute elements ---------------- */
  359.  
  360. cgm_result
  361.     cgm_LINE_BUNDLE_INDEX(P2(cgm_state *, cgm_int)),
  362.     cgm_LINE_TYPE(P2(cgm_state *, cgm_line_type)),
  363.     cgm_LINE_WIDTH(P2(cgm_state *, const cgm_line_width *)),
  364.     cgm_LINE_COLOR(P2(cgm_state *, const cgm_color *)),
  365.     cgm_MARKER_BUNDLE_INDEX(P2(cgm_state *, cgm_int)),
  366.     cgm_MARKER_TYPE(P2(cgm_state *, cgm_marker_type)),
  367.     cgm_MARKER_SIZE(P2(cgm_state *, const cgm_marker_size *)),
  368.     cgm_MARKER_COLOR(P2(cgm_state *, const cgm_color *)),
  369.     cgm_TEXT_BUNDLE_INDEX(P2(cgm_state *, cgm_int)),
  370.     cgm_TEXT_FONT_INDEX(P2(cgm_state *, cgm_int)),
  371.     cgm_TEXT_PRECISION(P2(cgm_state *, cgm_text_precision)),
  372.     cgm_CHARACTER_EXPANSION_FACTOR(P2(cgm_state *, cgm_real)),
  373.     cgm_CHARACTER_SPACING(P2(cgm_state *, cgm_real)),
  374.     cgm_TEXT_COLOR(P2(cgm_state *, const cgm_color *)),
  375.     cgm_CHARACTER_HEIGHT(P2(cgm_state *, const cgm_vdc *)),
  376.     cgm_CHARACTER_ORIENTATION(P5(cgm_state *, const cgm_vdc *,
  377.                      const cgm_vdc *, const cgm_vdc *,
  378.                      const cgm_vdc *)),
  379.     cgm_TEXT_PATH(P2(cgm_state *, cgm_text_path)),
  380.     cgm_TEXT_ALIGNMENT(P5(cgm_state *, cgm_text_alignment_horizontal,
  381.                   cgm_text_alignment_vertical,
  382.                   cgm_real, cgm_real)),
  383.     cgm_CHARACTER_SET_INDEX(P2(cgm_state *, cgm_int)),
  384.   /* The following should be cgm_ALTERNATE_..., but the VAX DEC C */
  385.   /* compiler gives an error for names longer than 31 characters. */
  386.     cgm_ALT_CHARACTER_SET_INDEX(P2(cgm_state *, cgm_int)),
  387.     cgm_FILL_BUNDLE_INDEX(P2(cgm_state *, cgm_int)),
  388.     cgm_INTERIOR_STYLE(P2(cgm_state *, cgm_interior_style)),
  389.     cgm_FILL_COLOR(P2(cgm_state *, const cgm_color *)),
  390.     cgm_HATCH_INDEX(P2(cgm_state *, cgm_hatch_index)),
  391.     cgm_PATTERN_INDEX(P2(cgm_state *, cgm_int)),
  392.     cgm_EDGE_BUNDLE_INDEX(P2(cgm_state *, cgm_int)),
  393.     cgm_EDGE_TYPE(P2(cgm_state *, cgm_edge_type)),
  394.     cgm_EDGE_WIDTH(P2(cgm_state *, const cgm_edge_width *)),
  395.     cgm_EDGE_COLOR(P2(cgm_state *, const cgm_color *)),
  396.     cgm_EDGE_VISIBILITY(P2(cgm_state *, bool)),
  397.     cgm_FILL_REFERENCE_POINT(P2(cgm_state *, const cgm_point *)),
  398. /* PATTERN_TABLE */
  399.     cgm_PATTERN_SIZE(P5(cgm_state *, const cgm_vdc *, const cgm_vdc *,
  400.                 const cgm_vdc *, const cgm_vdc *)),
  401.     cgm_COLOR_TABLE(P4(cgm_state *, cgm_int, const cgm_color *, int)),
  402.     cgm_ASPECT_SOURCE_FLAGS(P3(cgm_state *,
  403.                    const cgm_aspect_source_flag *, int));
  404.